/**
 * @param {number} num
 * @return {string}
*/
var convertToBase7 = function(num) {
  if(num == 0) return "0";
  let negative = false, result = "";
  if(num < 0) {
    num = -num;
    negative = true;
  }
  while(num) {
    result += (num % 7).toString();
    num = Math.floor(num / 7);
  }
  result = result.split("").reverse().join("");
  if(negative) result = "-" + result;
  return result;
};
let num = 100;
console.log(convertToBase7(num));
num = -7;
console.log(convertToBase7(num));
